from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy


class UserProfileAdmin(UserAdmin):
    # 需要显示的字段信息
    list_display = ['username', 'phone', 'email', 'is_active']
    # list_display = ['username', 'phone', 'email', 'group_list']
    # 设置哪些字段可以点击进入编辑界面，默认是第一个字段
    list_display_links = ['username', 'phone']
    # 后台搜索的字段
    search_fields = ['phone']
    # 后台排序的字段
    ordering = ['phone']
    # 添加用户页面可编辑字段
    fieldsets = (
        (None,
         {'fields': ('username', 'password', 'phone', 'email')}),

        (gettext_lazy('User Information'),
         {'fields': ('gender', 'birthday', 'nickname', 'card_id', 'photo', 'address')}),

        (gettext_lazy('Permissions'),
         {'fields': ('is_superuser', 'is_staff', 'is_active', 'groups', 'user_permissions')}),

        (gettext_lazy('Important dates'),
         {'fields': ('last_login',)}),
    )
    # 添加账户时显示要填写的字段
    add_fieldsets = (('添加账户',
                      {'classes': ('wide',),
                       'fields': ('username', 'password1', 'password2', 'phone')}),
                     )

# class GroupsAdmin(admin.ModelAdmin):
#     list_display = ['gid', 'name', 'user_list']


